<?php

/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2023/9/22 10:20
 * Desc: 优惠券
 */
class Request_Api_V2_Coupon extends Request_Api_V2_Base
{
    public function __construct($request_param)
    {
        parent::__construct($request_param);

        // 检查用户
        $no_user_check = [
            'api/v2/coupon/get_coupon_list',
            'api/v2/coupon/receive_coupon_list',
        ];
        if (!in_array($this->request_param['method'], $no_user_check)) {
            $this->validation->rule('mid', array('Rule_Member', 'need_member'));
        }
    }

    public function receive_list()
    {
        $this->rules = [
            ['pagesize', ['digit', $this->rule_min(1)]],
            ['page', ['digit', $this->rule_min(1)]],
            ['typeid', ['digit', $this->rule_min(1)]]
        ];

        return $this;
    }

    public function receive()
    {
        $this->rules = [
            ['id', ['not_empty', 'digit', $this->rule_min(1)]]
        ];

        return $this;
    }

    public function member_coupon()
    {
        $this->rules = [
            ['pagesize', ['digit', $this->rule_min(1)]],
            ['page', ['digit', $this->rule_min(1)]],
            ['typeid', ['digit', $this->rule_min(0)]]
        ];

        return $this;
    }

    public function member_coupon_jifen()
    {
        $this->rules = [
            ['pagesize', ['digit', $this->rule_min(1)]],
            ['page', ['digit', $this->rule_min(1)]],
            ['typeid', ['digit', $this->rule_min(0)]]
        ];

        return $this;
    }

    public function product_use_list()
    {
        $this->rules = [
            ['model_type_id', ['not_empty', 'digit', $this->rule_min(1)]],
            ['product_id', ['not_empty']]
        ];

        return $this;
    }

    public function get_coupon_category()
    {
        return $this;
    }

    public function use_product()
    {
        $this->rules = [
            ['cid', ['not_empty', 'digit', $this->rule_min(1)]],
            ['typeid', ['digit', $this->rule_min(1)]],
            ['page', ['digit', $this->rule_min(1)]],
        ];

        return $this;
    }

    public function get_coupon_list()
    {
        $this->rules = [
            ['type_id', ['not_empty', 'digit', $this->rule_min(1)]],
            ['product_id', ['not_empty','digit', $this->rule_min(1)]],
        ];

        return $this;
    }

    public function check_samount()
    {
        $this->rules = [
            ['total_price', ['not_empty']],
            ['role_id', ['not_empty', 'digit', $this->rule_min(1)]],
            ['type_id', ['not_empty', 'digit', $this->rule_min(1)]],
            ['product_id', ['not_empty']],
        ];

        return $this;
    }


}